package threadDemo12;

public class Cook extends Thread{
    @Override
    public void run() {
        while (true){
            synchronized (Desk.lock){
                //判断食物是否吃完了
                if (Desk.count==0){
                    break;
                }
                //判断桌上是否有食物
                if (Desk.foodFlag==1){
                    //等待
                    try {
                        Desk.lock.wait();
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }else {
                    System.out.println("制作了一碗面条");
                    //修改桌上食物状态
                    Desk.foodFlag=1;
                    //唤醒
                    Desk.lock.notifyAll();
                }
            }

        }

    }
}
